package main

import (
	"fmt"
	"math"
)

func main() {
	hello()
	dataType()
}

func hello() {
	fmt.Println("hello world")
}

func dataType() {
	var a uint = 12
	var a2 uint8 = 12
	var a3 uint32 = 12
	var a4 uint64 = 12
	var a5 int8 = 12
	fmt.Println(a)
	fmt.Println(a2)
	fmt.Println(a3)
	fmt.Println(a4)
	fmt.Println(a5)

	var f1 float32 = 12.1
	var f2 float64 = 12.12
	fmt.Println(f1)
	fmt.Println(f2)

	var c1 complex64 = 12
	var c2 complex128 = 12
	fmt.Println(c1)
	fmt.Println(c2)

	var b byte = 12
	var r rune = 21
	var ui uint = 12
	var i int = 22
	fmt.Println(b)
	fmt.Println(r)
	fmt.Println(ui)
	fmt.Println(i)

	var _bool bool = true
	fmt.Println(_bool)

	ab := 123
	fmt.Println(ab)
	fmt.Println(&ab)
	const PIZ = "pzi"
	fmt.Println(PIZ)
	fmt.Println(math.Pi)
	condition(1)
	condition(-1)
}

func condition(n int) {
	if n > 0 {
		fmt.Print("n>0:")
		fmt.Println(n)
	} else if n < 0 {
		fmt.Print("n<0:")
		fmt.Println(n)
	}

	switch {
		case n > 0:
			fmt.Print("n>0:")
			fmt.Println(n)
		case n < 0:
			fmt.Print("n>0:")
			fmt.Println(n)
	}

	loop()
}

func loop()  {
	var b int = 15
	var a int

	numbers := [6]int{1, 2, 3, 5}

	/* for 循环 */
	for a := 0; a < 10; a++ {
		fmt.Printf("a 的值为: %d\n", a)
	}

	for a < b {
		a++
		fmt.Printf("a 的值为: %d\n", a)
	}

	for i,x:= range numbers {
		fmt.Printf("第 %d 位 x 的值 = %d\n", i,x)
	}
}
